package com.shg.web.ztest;


import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.shg.bean.Online;
import com.shg.bean.Shop;
import com.shg.bean.Users;
import com.shg.service.ShopService;
import com.shg.service.UsersService;

public class ShopServiceTest {

	private static ShopService shopService;
	
	private static UsersService usersService;
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		ApplicationContext context=new ClassPathXmlApplicationContext("basics-application.xml");
		shopService=(ShopService)context.getBean("shopServiceBean");
		usersService=(UsersService)context.getBean("usersServiceBean");
	}

	@Test
	public void testInsert() {
		Users users=null;
		try {
			users = (Users) usersService.select(Users.class, "402889603598fafa01359902f6410001");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Shop shop=new Shop();
		shop.setShopName("新华书店");
		shop.setCoName("书皇科技有限公司");
		shop.setCoAddress("广西  南宁市  火炬路1号创业大厦六楼");
		shop.setUsers(users);
		shopService.insert(shop);
	}
	@Test
	public void testShop(){
		Shop shop=null;
		try {
			shop = shopService.getIntoshop("ff80808135a033220135a033246c0000");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		for(Online online:shop.getChilds()){
			System.out.println(online.getUserName());
		}
	}
}
